package com.fengye.common.exception;

import com.fengye.common.constants.AppHttpCodeEnum;

/**
 * @author sunlei
 * @description 自定义异常基类
 */
public class BusinessException extends RuntimeException {
    private AppHttpCodeEnum errorEnum;

    private BusinessException() {
        super();
    }

    private BusinessException(String message) {
        super(message);
    }

    private BusinessException(String message, Throwable cause) {
        super(message, cause);
    }

    private BusinessException(Throwable cause) {
        super(cause);
    }

    private BusinessException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    // 公开的构造函数
    public BusinessException(AppHttpCodeEnum errorEnum) {
        super(errorEnum.getMsg());
        this.errorEnum = errorEnum;
    }

    public BusinessException(AppHttpCodeEnum errorEnum, String message) {
        super(message);
        this.errorEnum = errorEnum;
    }

    // getter、setter
    public AppHttpCodeEnum getErrorEnum() {
        return errorEnum;
    }

    public void setErrorEnum(AppHttpCodeEnum errorEnum) {
        this.errorEnum = errorEnum;
    }
}
